<template>
    <div class="tech-setcookie">
        <Row class="filed-item">
            <Field label="品牌ID" placeholder="输入品牌id" v-model="brandId" />
        </Row>
        <Row class="filed-item">
            <Field label="品牌名称" placeholder="输入品牌id" v-model="brandName" />
        </Row>
        <Row class="filed-item">
            <Field label="模式" placeholder="输入品牌id" v-model="operationMode" />
        </Row>
        <div class="tip-info">1~品牌统一管理商品，2~门店专场模式，3~经销商模式</div>
        <Row class="filed-item">
            <Col span="4">允许预约</Col>
            <Col span="20">
                <vSwitch v-model="allowBooking" />
            </Col>
        </Row>
        <Row class="filed-item">
            <Field label="可预约天数" placeholder="输入天数" v-model="bookingDays" />
        </Row>
        <Row class="filed-item">
            <Field label="memberId" placeholder="输入memberId" v-model="memberId" />
        </Row>
        <Row class="filed-item">
            <Field label="token" placeholder="输入token" type="textarea" v-model="token" :autosize="{minHeight: 220, maxHeight: 300}" />
        </Row>
        <Row class="filed-item">
            <Field label="mode" placeholder="mode" v-model="mode" />
        </Row>
        <Row class="filed-item">
            <Field label="theme" placeholder="theme" v-model="theme" />
        </Row>
        <Row class="filed-item">
            <Field label="styleMode" placeholder="styleMode" v-model="styleMode" />
        </Row>
        <Button class="btn" type="danger" @click="setCookies">设置cookie</Button>
        <Button class="btn" type="danger" @click="goToShopOrderList">订单列表</Button>
        <Button class="btn" type="danger" @click="goToShopClassify">分组</Button>
        <Button class="btn" type="danger" @click="goToShopBag">购物车</Button>
        <Button class="btn" type="danger" @click="goToGoodsAfterList">售后单列表</Button>
        <Button class="btn" type="danger" @click="goToReview">确认订单</Button>
        <Button class="btn" type="danger" @click="goToDetail">详情</Button>
        <Button class="btn" type="danger" @click="goToSpecial">专场</Button>
        <Button class="btn" type="danger" @click="goToAddress">地址管理</Button>
    </div>
</template>

<script>
import { Row, Col, Field, Button, Switch } from 'vant';
import { setBrandIdCookie, setUserMemberIdCookie, setUserTokenCookie, clearAllCookies, setBrowserDebug,
    setUiMode, setUiTheme, setUiStyleMode, setBrandNameCookie, setBrandAllowBooking, setBrandBookingDays } from '@biztools/info';
import { DEFAULT_MODE, DEFAULT_THEME, DEFAULT_STYLE_MODE } from '@constants/style';
import { redirectTo } from '@common/utils';
import { setInfo } from '@common/storage';
export default {
    name: 'SetCookie',
    components: {
        Row,
        Col,
        Field,
        Button,
        vSwitch: Switch,
    },
    data() {
        return {
            brandId: '43',
            brandName: '薅羊毛',
            operationMode: 1,
            allowBooking: true,
            bookingDays: 7,
            memberId: '12',
            token: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjI2MDIyOTUsImlhdCI6MTYyMTk5NzQ5NSwibWVtYmVyX2lkIjoxMiwiYnJhbmRfaWQiOjQzLCJvcGVuX2lkIjoib08yNFA0NDVreGZzVG90b1kwZTNvY0xsUHU5ayIsImFwcF9pZCI6Ind4MjUwZDEzMzFhNWJjNGFlNSIsImJpbGluX2FwcCI6Im1hbGxfbWluYSJ9.s0Ag-KZkJMhEez-_nLc7b3WV4tcsQ8H8lWaO676JsQNgg--ET45Mc0YlYHUWEKcivKGnTsWcUdMMP4fR0fBUZMIihZuk45ds1hDJpu6J5rXA5EJzLmGyNeIdJistVjVtj5gN9KBI6u1eZfz2eApfXaQbFfAGb64pDFaNIsfuknU',
            mode: DEFAULT_MODE,
            theme: DEFAULT_THEME,
            styleMode: DEFAULT_STYLE_MODE,
        };
    },
    methods: {
        setCookies() {
            clearAllCookies();
            setBrowserDebug();
            // 保存品牌id
            setBrandIdCookie(this.brandId);
            // 保存品牌名称
            setBrandNameCookie(this.brandName);
            setBrandAllowBooking(this.allowBooking);
            setBrandAllowBooking(this.bookingDays);
            // 保存memberId
            setUserMemberIdCookie(this.memberId);
            // 保存token
            setUserTokenCookie(this.token);
            setUiMode(this.mode);
            setUiTheme(this.theme);
            setUiStyleMode(this.styleMode);
        },
        goToAddress() {
            redirectTo('member/owner/address');
        },
        goToShop() {
            redirectTo('shop');
        },
        goToShopBag() {
            redirectTo('shop/bag');
        },
        goToShopOrderList() {
            redirectTo('shop-order/list');
        },
        goToShopClassify() {
            redirectTo('shop/classify');
        },
        goToGoodsAfterList() {
            redirectTo('shop-order/after-sale/goods-list');
        },
        goToReview() {
            redirectTo('shop/review');
        },
        goToDetail() {
            redirectTo(`shop/detail/${1}`);
        },
        goToSpecial() {
            redirectTo(`shop/special/${44}`);
        },
    },
};
</script>

<style lang="less" scoped>
.tech-setcookie {
    padding-bottom: 0;
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    .p-h(@gap-sm);
    .tip-info {
        font-size: 12px;
        color: @gray-darker;
        padding: 10px 0;
    }
    .filed-item {
        .m-v(@gap-sm);
        border: 1px solid @gray;
        .label {
            .flex-row-center();
            height: 100%;;
        }
    }
    .van-field--min-height .van-field__control {
        min-height: 280px;
    }
    .btn {
        width: 100%;
        margin-bottom: 15px;
    }
}
</style>
